
\includegraphics[scale=.75]{block_diagram.png}

I designed the project to be modular so that it would be easier to organize the code.  Each box in the above diagram corresponds to an Objective Caml source file, with the exception of the scannar/parser which corresponds to two Object Caml source files.  The scanner and parser performs the lexical analysis needed to convert the source files into the abstract syntax tree (AST).  Translate1 performs the initial semantic analysis to create the semantically checked syntax tree (SAST), however it does not resolve the dimensionality of the neurons or expressions.  Translate2 propagates the dimensionality from the parameters and neurons that have been explicitly given to the rest of the parameters and neurons.  If it stops being able to disambiguate the program when there are still ambiguous expressions, then an error is thrown.

Once the SAST is disambiguated by Translate2, Validate runs some checks, mainly to check that there isn't anything that is still ambiguous.  Initially I intended Validate to do more, including checking the result of Translate1.  The validated SAST is then used by Synap to run the program with the help of Ppm (for reading in PPM images), Params (which includes code specific to handling parameters), and Eval (which performs the expression evaluations).

The SAST interface defines the expression tree as being a combination of expr\_detail and a type defined in Types.  The types allowed are:

\begin{enumerate}
\item Int - expressions in indices must have this type.
\item Matrix - floats and multidimensional have this type.  This type specifies the dimensionality as a list of ints.  Floats are specified with a list of a single element of ``1.''
\item MatrixUnknownSize - this is the type given to ambiguous expressions where the size is not known.  This can only be in the SAST between the Translate1 and Translate2
\end{enumerate}